package com.dragon.repository.mapper;

import com.dragon.repository.entity.ContractFit;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 合同设置 Mapper 接口
 * </p>
 *
 * @author sy
 * @since 2023-11-08
 */
@Mapper
public interface ContractFitMapper extends BaseMapper<ContractFit> {

    /**
     * 详情
     * @param id
     * @return
     */
    @Select("SELECT M.*, N.username as produceUsername, N1.username as payeeUsername FROM " +
            "(select dcf.*,da.username as deliverUsername from dragon_contract_fit dcf " +
            "LEFT JOIN dragon_admin da on dcf.deliver_admin_id = da.id)M " +
            "LEFT JOIN dragon_admin N on M.produce_admin_id = N.id " +
            "LEFT JOIN dragon_admin N1 on M.payee_admin_id = N1.id WHERE M.id = #{id}")
    ContractFit selectDetail(Integer id);
}
